/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import vo.VOKeyword;

/**
 *
 * @author sbaldrich
 */
@Entity
@Table(name = "keyword")
@NamedQueries(
{
    @NamedQuery(name = "Keyword.findAll", query = "SELECT k FROM Keyword k"),
    @NamedQuery(name = "Keyword.findByIdKeyword", query = "SELECT k FROM Keyword k WHERE k.idKeyword = :idKeyword"),
    @NamedQuery(name = "Keyword.findByName", query = "SELECT k FROM Keyword k WHERE k.name = :name")
})
public class Keyword implements Serializable
{

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idKeyword")
    private Integer idKeyword;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @ManyToMany(mappedBy = "keywordList")
    private List<Problem> problemList;

    public Keyword()
    {
    }

    public Keyword(Integer idKeyword)
    {
        this.idKeyword = idKeyword;
    }

    public Keyword(Integer idKeyword, String name)
    {
        this.idKeyword = idKeyword;
        this.name = name;
    }

    public Keyword(VOKeyword vo)
    {
        this.setName(vo.getName());
        this.setIdKeyword(vo.getIdKeyword());
    }

    public Integer getIdKeyword()
    {
        return idKeyword;
    }

    public void setIdKeyword(Integer idKeyword)
    {
        this.idKeyword = idKeyword;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public List<Problem> getProblemList()
    {
        return problemList;
    }

    public void setProblemList(List<Problem> problemList)
    {
        this.problemList = problemList;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (idKeyword != null ? idKeyword.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Keyword))
        {
            return false;
        }
        Keyword other = (Keyword) object;
        if ((this.idKeyword == null && other.idKeyword != null) || (this.idKeyword != null && !this.idKeyword.equals(other.idKeyword)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "entities.Keyword[idKeyword=" + idKeyword + "]";
    }

    public VOKeyword getVO()
    {
        return new VOKeyword(this);
    }
}
